﻿using System;
using System.Text.RegularExpressions;

namespace Paladyne.FileSearch.Core
{
    /// <summary>
    /// The simplest implementation of text comparison and substring search
    /// </summary>
    public class DefaultTextCompareStrategy : ITextCompareStrategy
    {
        #region Implementation of ITextCompareStrategy

        public bool Contains(string text, string searchString, bool ignoreCase)
        {
            return Regex.IsMatch(text, Regex.Escape(searchString), ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None);
        }

        public bool AreEqual(string text1, string text2, bool ignoreCase)
        {
            return String.Compare(text1, text2, ignoreCase) == 0;
        }

        #endregion
    }
}